/*
 * Q1C.cxx
 *
 *  Created on: 6:37:49 PM Sep 18, 2012
 *      Author: Pallab
 * "I have not failed, I have just found 10000 ways that won't work.
 */

#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <bitset>
#include <iomanip>

#include <ctime>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>
#include <cstdlib>

using namespace std;

#define foR(i1,st,ed) for(int i1 = st , j1 = ed ; i1 < j1 ; ++i1 )
#define fo(i1,ed) foR( i1 , 0 , ed )
#define foE(i1,st,ed) foR( i1, st, ed+1 )
#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define bip system("pause")
#define Int long long
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define mk make_pair
#define SET( ARRAY , VALUE ) memset( ARRAY , VALUE , sizeof(ARRAY) )
#define line puts("")

inline void wait(double seconds){
	double endtime = clock() + (seconds * CLOCKS_PER_SEC);
	while ( clock() < endtime ){
		;
	}
}
#define T int
inline T fastIn(){
	register char c = 0;
	register T a = 0;
	while ( c < 33 )
		c = getchar();
	while ( c > 33 ){
		a = (a * 10) + (c - '0');
		c = getchar();
	}
	return a;
}
int command_count;
string cur_line;
string print_line;
inline string parse(string mystr){
    char *sentence = (char*)mystr.c_str(); // string to chat array
    char *word;
    static char delim[]="/";
    deque<string> words;
    for(word=strtok(sentence,delim);word; word=strtok(0,delim)){
        if( strlen(word) ){
            if( strcmp(word,"..")==0 ){
            	if( words.empty()==false ){
            		words.pop_back();
            	}
            }
            else
                 words.push_back((string)word);
        }
    }

    string dummy="/";
    fo(i,SZ(words)){
    	dummy+=(words[i]+'/');
    }
    //printf("was, get => %s_-->_%s_\n",mystr.c_str(),dummy.c_str());
    return dummy;
}
inline void solve(string cur_line){
	print_line = parse( cur_line[0]=='/'? cur_line : print_line+cur_line);
}
inline void proc(){
	print_line="/";
	scanf("%d\n",&command_count);
	fo(i,command_count){
		getline(cin,cur_line);
		if( cur_line=="pwd" ){
			puts(print_line.c_str());
		}
		else{
			solve( cur_line.substr(3) );
		}
	}
}

//#define ME
int main(){
	int kase = 1;
#if defined ( ME )
	freopen("in", "r", stdin);
	kase = 1;
#endif
	fo(i,kase){
		proc();
	}
	return 0;
}







